home *** CD-ROM | disk | FTP | other *** search
/ isnet Internet / Isnet Internet CD.iso / prog / chat / 12 / 12.exe / SYSTEM / NOTES.MRC < prev    next >
Encoding:
Text File  |  2000-02-16  |  4.3 KB  |  158 lines

  1. ;%%%%%%%%%%%%%%%%%%%%%%%%
  2. ;script Notes support
  3. ;version 7.20
  4. ;author BARtMAN, Quietust
  5. ;email bartman@ircN.org
  6. ;url http://www.ircN.org
  7. ;%%%%%%%%%%%%%%%%%%%%%%%%
  8. on 1:CONNECT {
  9.   if (%cn.time == $null) set %cn.time 3600
  10.   .timer 0 %cn.time notes.check
  11. }
  12. on 1:START {
  13.   if ($exists(notes.dat) == $false) write -c notes.dat
  14.   notes.expire
  15. }
  16. alias notes.expire {
  17.   var %a, %b, %z
  18.   set %a 1
  19.   while ($read -nl $+ %a notes.dat != $null) {
  20.     set %z $ifmatch
  21.     if ($calc($ctime - (86400 * 30)) >= $gettok(%z,3,32)) {
  22.       inc %b
  23.       write -dl $+ %a notes.dat
  24.       dec %a
  25.     }
  26.     inc %a
  27.   }   
  28.   if (%b != $null) iecho %b $iif(%b == 1,note was,notes were) 30 days or more old and have been deleted.
  29. }
  30. on 1:JOIN:# {
  31.   if (%notes.sent. [ $+ [ $nick ] ] ) return
  32.   var %a, %b, %y, %z
  33.   set %y $usrh($fulladdress)
  34.   set %a 1
  35.   while ($read -nl $+ %a notes.dat != $null) {
  36.     set %z $gettok($ifmatch,1,32)
  37.     if (%z == %y) inc %b
  38.     inc %a
  39.   }
  40.   if (%b != $null) {
  41.     .notice $nick You have %b $iif(%b == 1,note,notes) waiting on $me $+ .
  42.     .notice $nick For a list, /CTCP $me NOTES [pass] INDEX
  43.   }
  44.   set -u30 %note.sent. [ $+ [ $nick ] ] $true
  45. }
  46. ctcp 40:NOTES *:? {
  47.   var %z = $usrh($fulladdress)
  48.   if ($2 === $password(%z)) {
  49.     if ($3 == index) notes.index %z $nick
  50.     elseif ($3 == read) notes.read %z $nick $4
  51.     elseif ($3 == erase) notes.erase %z $nick $4
  52.     elseif ($3 == to) notes.to %z $nick $4-
  53.   }
  54. }
  55. alias -l notes.index {
  56.   var %a, %b, %z
  57.   set %a 1
  58.   while ($read -nl $+ %a notes.dat != $null) {
  59.     set %z $ifmatch
  60.     if ($gettok($ifmatch,1,32) == $1) {
  61.       inc %b
  62.       .notice $2 $lfix(3,%b) $+ . $gettok(%z,2,32) ( $+ $asctime($gettok(%z,3,32),mmm d H:ss z) GMT)
  63.     }
  64.     inc %a
  65.   }
  66.   if (%b != $null) .notice $2 ( $+ %b total)
  67.   else .notice $2 You have no messages.
  68. }
  69. alias -l notes.read {
  70.   var %a, %b, %y, %z
  71.   set %y $notes.num($3)
  72.   set %a 1
  73.   while ($read -nl $+ %a notes.dat != $null) {
  74.     set %z $ifmatch
  75.     if ($1 == $gettok(%z,1,32)) {
  76.       inc %b
  77.       if (($3 == all) || ($3 == $null) || ($istok(%y,%b,32) == $true)) .notice $2 $lfix(3,%b) $+ . $gettok(%z,2,32) ( $+ $asctime($gettok(%z,3,32),mmm d H:ss z) GMT): $gettok(%z,4-,32)
  78.     }
  79.     inc %a
  80.   }
  81.   if (%b == $null) .notice $nick You have no messages.
  82. }
  83. alias -l notes.erase {
  84.   var %a, %b, %c, %y, %z
  85.   set %y $notes.num($3)
  86.   set %a 1
  87.   while ($read -nl $+ %a notes.dat != $null) {
  88.     set %z $gettok($ifmatch,1,32)
  89.     if (%z == $1) {
  90.       inc %b
  91.       if (($3 == all) || ($3 == $null) || ($istok(%y,%b,32) == $true)) {
  92.         write -dl $+ %a notes.dat
  93.         dec %a
  94.         inc %c
  95.       }
  96.     }
  97.     inc %a
  98.   }
  99.   if (%c != $null) {
  100.     if (%c == %b) .notice $2 Erased all notes.
  101.     else .notice $2 Erased %c $iif(%c == 1,note,notes) $+ ; $calc(%b - %c) left.
  102.   }
  103.   else .notice $nick You have no messages.
  104. }
  105. alias -l notes.to {
  106.   if ($usrhost($3) == $null) {
  107.     if ($usr($3) != $null) .notice $2 No such username; try $ifmatch $+ .
  108.     else .notice $2 No such username!
  109.   }
  110.   elseif ($4 == $null) .notice $2 Syntax: /ctcp $me NOTES TO <username> <message>
  111.   elseif ($usrhost($3) != $null) {
  112.     write notes.dat $3 $1 $ctime $4-
  113.     .notice $2 Note delivered.
  114.   }
  115. }
  116. alias notes.check {
  117.   var %a, %b, %c, %d, %e, %v, %w, %x, %y, %z
  118.   set %a 1
  119.   while ($read -nl $+ %a notes.dat != $null) {
  120.     set %z $usrhost($gettok($ifmatch,1,32))
  121.     set %b 1
  122.     while ($gettok(%z,%b,32) != $null) {
  123.       set %y $ifmatch
  124.       set %c 1
  125.       while ($ial(%y,%c).nick != $null) {
  126.         set %x $ifmatch
  127.         if ($wildtok(%w,$addtok(%x,*,44),1,32) != $null) set %w $reptok(%w,$ifmatch,$addtok(%x,$calc($gettok($ifmatch,2,44) + 1),44),1,32)
  128.         else set %w $addtok(%w,$addtok(%x,1,44),32)
  129.         inc %c
  130.       }
  131.       inc %b
  132.     }
  133.     inc %a
  134.   }
  135.   set %d 1
  136.   while ($gettok(%w,%d,32) != $null) {
  137.     set %v $gettok($ifmatch,1,44)
  138.     set %e $gettok($ifmatch,2,44)
  139.     .timer 1 %d .notice %v You have %e $iif(%e == 1,note,notes) waiting on $me $+ .
  140.     .timer 1 $calc(%d + 1) .notice %v For a list, /CTCP $me NOTES [pass] INDEX
  141.     inc %d
  142.   }
  143. }
  144. alias notes.num {
  145.   var %a, %y, %z
  146.   set %a 1
  147.   while (%a <= $iif($2 != $null,$2,25)) {
  148.     set %y %y %a
  149.     inc %a
  150.   }
  151.   set %a 1
  152.   while ($gettok($1,%a,59) != $null) {
  153.     set %z %z $gettok(%y,$ifmatch,32)
  154.     inc %a
  155.   }
  156.   return %z
  157. }
  158.